Change in openvpn[master]: socket: restore per-connection lport override over global default
A message that is not in the archive (sent off-list or not yet received): gerrit.1772625635000.I7cf5d5ef7e2531f397ad97baf4663e3763072f6b@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
to review the following change.
Change subject: socket: restore per-connection lport override over global default
......................................................................
socket: restore per-connection lport override over global default
OpenVPN 2.7.x introduced a regression where --lport specified inside a <connection> block did not override a globally defined local port. As a result, the socket was bound to the global default port instead of the per-connection value.
Adjust the socket local_port selection logic to honour local_port_defined when set for the active connection profile.
This change restores the documented and previously working behaviour from 2.6.x, where connection-level lport takes precedence over global defaults.
Github: #995
---
M src/openvpn/socket.c
1 file changed, 3 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1555/1
src/openvpn/socket.c +3 -1
@@ -1347,7 +1347,9 @@ASSERT (sock);const char *host = o->ce.local_list->array[sock_index]->local; -const char *port = o->ce.local_list->array[sock_index]->port; +const char *port = (o->mode ==MODE_POINT_TO_POINT && o->ce.local_port_defined) + ? o->ce.local_port + : o->ce.local_list->array[sock_index]->port;int proto = o->ce.local_list->array[sock_index]->proto;const char *remote_host = o->ce.remote;const char *remote_port = o->ce.remote_port;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: its_Giaan, plaisthos.
ordex has posted comments on this change by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email )
Change subject: socket: restore per-connection lport override over global default
......................................................................
Patch Set 1: Code-Review-1
(1 comment)
File src/openvpn/socket.c:
http://gerrit.openvpn.net/c/openvpn/+/1555/comment/29141286_321bf2c0?usp=email :
PS1, Line 1350: const char *port = (o->mode == MODE_POINT_TO_POINT && o->ce.local_port_defined)
similarly to what we do with o->ce.proto, can we have an if just below the variables declaration, rather than having this longer/complex expression in here?
we could just have:
if (o->mode == MODE_POINT_TO_POINT && o->ce.local_port_defined)
{
port = o->ce.local_port
}and keep the variable declaration/initialization as it was before.
Maybe also add a comment of top of that if saying something like "if --lport is specified in a client connection block we give it higher priority"
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Comment-Date: Tue, 10 Mar 2026 13:42:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: its_Giaan, ordex, plaisthos.
Hello ordex, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by ordex
Change subject: socket: restore per-connection lport override over global default
......................................................................
socket: restore per-connection lport override over global default
OpenVPN 2.7.x introduced a regression where --lport specified inside a <connection> block did not override a globally defined local port. As a result, the socket was bound to the global default port instead of the per-connection value.
Adjust the socket local_port selection logic to honour local_port_defined when set for the active connection profile.
This change restores the documented and previously working behaviour from 2.6.x, where connection-level lport takes precedence over global defaults.
Github: #995
---
M src/openvpn/socket.c
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1555/2
src/openvpn/socket.c +7 -0
@@ -1357,6 +1357,13 @@ proto = o->ce.proto; } +/* If --lport is specified in a client connection block, +* it takes precedence over the global setting. */ +if (o->mode ==MODE_POINT_TO_POINT && o->ce.local_port_defined) + { + port = o->ce.local_port; + } +if (c->mode ==CM_CHILD_TCP || c->mode ==CM_CHILD_UDP ) {struct link_socket *tmp_sock =NULL ;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Attention is currently required from: ordex, plaisthos.
its_Giaan has posted comments on this change by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email )
Change subject: socket: restore per-connection lport override over global default
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/socket.c:
http://gerrit.openvpn.net/c/openvpn/+/1555/comment/21d779a6_4ec1a1d6?usp=email :
PS1, Line 1350: const char *port = (o->mode == MODE_POINT_TO_POINT && o->ce.local_port_defined)
Quoted 1 line
similarly to what we do with
o->ce. […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: ordex <[email protected]...>
Gerrit-Comment-Date: Tue, 10 Mar 2026 16:20:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: ordex <[email protected]...>
Attention is currently required from: its_Giaan, plaisthos.
ordex has posted comments on this change by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email )
Change subject: socket: restore per-connection lport override over global default
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
Patchset:
PS2:
Maybe Gert can fix the comment by moving the ending "*/" on a new line. The rest looks good to me!
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Comment-Date: Mon, 16 Mar 2026 13:46:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
PATCH v2 1/1 socket: restore per-connection lport override over global default
In reply to a message not in the archiveFrom: Gianmarco De Gregori <[email protected]...>
OpenVPN 2.7.x introduced a regression where --lport specified inside a <connection> block did not override a globally defined local port. As a result, the socket was bound to the global default port instead of the per-connection value.
Adjust the socket local_port selection logic to honour local_port_defined when set for the active connection profile.
This change restores the documented and previously working behaviour from 2.6.x, where connection-level lport takes precedence over global defaults.
Github: #995
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1555
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1555
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Antonio Quartulli <[email protected]...>
src/openvpn/socket.c +7 -0
@@ -1357,6 +1357,13 @@ proto = o->ce.proto; } +/* If --lport is specified in a client connection block, +* it takes precedence over the global setting. */ +if (o->mode ==MODE_POINT_TO_POINT && o->ce.local_port_defined) + { + port = o->ce.local_port; + } +if (c->mode ==CM_CHILD_TCP || c->mode ==CM_CHILD_UDP ) {struct link_socket *tmp_sock =NULL ;
[Openvpn-devel] [PATCH applied] Re: socket: restore per-connection lport override over global default
Thanks for the fix.
The change passes all BB and t_server tests, though this is mostly meaningless here - no <connection> blocks are excercised. So I ran this with a quick local config setup, with a global --lport and two <connection> profiles, one of them with a local --lport, verifying that it indeed is honoured.
Your patch has been applied to the master and release/2.7 branch (bugfix).
commit 7ac5f89023b2c2870a210016a862ec042f709bb7 (master) commit b5039975bf629d33fbff0b0feae6d072378e7edc (release/2.7)
Author: Gianmarco De Gregori Date: Mon Mar 16 14:48:36 2026 +0100
socket: restore per-connection lport override over global default
Signed-off-by: Gianmarco De Gregori <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1555
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36164.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by ordex
Change subject: socket: restore per-connection lport override over global default
......................................................................
socket: restore per-connection lport override over global default
OpenVPN 2.7.x introduced a regression where --lport specified inside a <connection> block did not override a globally defined local port. As a result, the socket was bound to the global default port instead of the per-connection value.
Adjust the socket local_port selection logic to honour local_port_defined when set for the active connection profile.
This change restores the documented and previously working behaviour from 2.6.x, where connection-level lport takes precedence over global defaults.
Github: closes OpenVPN/openvpn#995
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1555
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36164.html
---
M src/openvpn/socket.c
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/1555/3
src/openvpn/socket.c +7 -0
@@ -1357,6 +1357,13 @@ proto = o->ce.proto; } +/* If --lport is specified in a client connection block, +* it takes precedence over the global setting. */ +if (o->mode ==MODE_POINT_TO_POINT && o->ce.local_port_defined) + { + port = o->ce.local_port; + } +if (c->mode ==CM_CHILD_TCP || c->mode ==CM_CHILD_UDP ) {struct link_socket *tmp_sock =NULL ;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email )
Change subject: socket: restore per-connection lport override over global default
......................................................................
socket: restore per-connection lport override over global default
OpenVPN 2.7.x introduced a regression where --lport specified inside a <connection> block did not override a globally defined local port. As a result, the socket was bound to the global default port instead of the per-connection value.
Adjust the socket local_port selection logic to honour local_port_defined when set for the active connection profile.
This change restores the documented and previously working behaviour from 2.6.x, where connection-level lport takes precedence over global defaults.
Github: closes OpenVPN/openvpn#995
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1555
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36164.html
---
M src/openvpn/socket.c
1 file changed, 7 insertions(+), 0 deletions(-)
src/openvpn/socket.c +7 -0
@@ -1357,6 +1357,13 @@ proto = o->ce.proto; } +/* If --lport is specified in a client connection block, +* it takes precedence over the global setting. */ +if (o->mode ==MODE_POINT_TO_POINT && o->ce.local_port_defined) + { + port = o->ce.local_port; + } +if (c->mode ==CM_CHILD_TCP || c->mode ==CM_CHILD_UDP ) {struct link_socket *tmp_sock =NULL ;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1555?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7cf5d5ef7e2531f397ad97baf4663e3763072f6b
Gerrit-Change-Number: 1555
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: ordex <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>